import Router from 'vue-router';
import Vue from 'vue';

Vue.use(Router)
const vueRouter = new Router({
  mode: 'history',
  routes: [
    {
      path: '/menu',
      name: 'menu',
      component: () => import( /* webpackChunkName: "page" */ '@/page/index'),
      children:[
        {
          path: '/menu/organization/:orgId',
          name: 'organization',
          component: () => import( /* webpackChunkName: "page" */ '@/page/menu/organization')
        },
        {
          path: 'category',
          name: 'category',
          component: () => import( /* webpackChunkName: "page" */ '@/page/menu/category')
        },
        {
          path: 'authority/:visualType/:appId',
          name: 'authority',
          component: () => import( /* webpackChunkName: "page" */ '@/page/menu/authority'),
          props: true
        },
        {
          path: '/menu/:visualType',
          name: 'menuVisualType',
          component: () => import( /* webpackChunkName: "page" */ '@/page/menu/index'),
        },
        // { path: '/', redirect: 'ThreeD' },
        // {
        //   path: 'data',
        //   name: 'data',
        //   component: () => import( /* webpackChunkName: "page" */ '@/page/menu/largescreen')
        // },
        // {
        //   path: 'map',
        //   name: 'map',
        //   component: () => import( /* webpackChunkName: "page" */ '@/page/menu/map')
        // },
        // {
        //   path: 'db',
        //   name: 'db',
        //   component: () => import( /* webpackChunkName: "page" */ '@/page/menu/db')
        // },
      ]
    },
    {
      path: '/account',
      name: 'account',
      component: () => import( /* webpackChunkName: "page" */ '@/page/account/index'),
      children: [
        {
          path: 'safe',
          name: 'safe',
          component: () => import( /* webpackChunkName: "page" */ '@/page/account/safe')
        },
        { path: '/', redirect: 'safe' }
      ]
    },
    {
      path: '/tenant',
      name: 'tenant',
      component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/index'),
      children: [
        {
          path: 'home',
          name: 'home',
          component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/home')
        },
        {
          path: 'role',
          name: 'role',
          component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/role')
        },
        {
          path: 'user',
          name: 'user',
          component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/user')
        },
        {
          path: 'tenant',
          name: 'tenantManage',
          component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/tenant')
        },
        {
          path: 'license',
          name: 'license',
          component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/license')
        },
        {
          path: 'dept',
          name: 'dept',
          component: () => import( /* webpackChunkName: "page" */ '@/page/tenant/dept')
        },
        { path: '/', redirect: 'home' }
      ]
    },
    {
      path: '/build/:id',
      name: 'build',
      component: () => import( /* webpackChunkName: "page" */ '@/page/build')
    },
    {
      path: '/workflow/:id',
      name: 'workflow',
      component: () => import( /* webpackChunkName: "page" */ '@/page/workflow')
    },
    {
      path: '/app/:appId',
      name: 'appId',
      component: () => import( /* webpackChunkName: "page" */ '@/page/app'),
      children: [
        {
          path: '/app/:appId/workflow',
          name: 'appWorkflow',
          component: () => import( /* webpackChunkName: "page" */ '@/page/app/workflow/workflowList'),
        },
        {
          path: '/app/:appId/:groupId',
          name: 'appGroupId',
          component: () => import( /* webpackChunkName: "page" */ '@/page/app/container'),
          children: [
            {
              path: '/app/:appId/:groupId/:worksheetId',
              name: 'appTableId',
              component: () => import( /* webpackChunkName: "page" */ '@/page/app/table'),
              meta: {
                isAuth: true,
                requireAuth: true,
                keepAlive: true // 用户列表需要被缓存
              }
            }
          ]
        },
      ]
    },
    {
      path: '/workflowedit/:appId/:id',
      name: 'workflowedit',
      component: () => import( /* webpackChunkName: "page" */ '@/page/app/workflow/workflowEdit'),
      // component: () => import( /* webpackChunkName: "page" */ '@/page/app/workflow/components/Main'),
      meta: {
        isAuth: false,
        requireAuth: false,
        keepAlive: true // 用户列表需要被缓存
      }
    },
    // {
    //   path: '/workflowInstance/:worksheetId/:rowId',
    //   name: 'share',
    //   component: () => import( /* webpackChunkName: "page" */ '@/page/app/workflowInstance'),
    //   meta: {
    //     isAuth: false,
    //     requireAuth: false,
    //     keepAlive: true // 用户列表需要被缓存
    //   }
    // },
    {
      path: '/share/:appId/:groupId/:worksheetId',
      name: 'share',
      component: () => import( /* webpackChunkName: "page" */ '@/page/app/share'),
      meta: {
        isAuth: false,
        requireAuth: false,
        keepAlive: true // 用户列表需要被缓存
      }
    },
    {
      path: '/public/form/:shareId',
      name: 'public',
      component: () => import( /* webpackChunkName: "page" */ '@/page/app/public/form'),
      meta: {
        isAuth: false,
        requireAuth: false,
        keepAlive: true // 用户列表需要被缓存
      }
    },
    {
      path: '/public/editor/:worksheetId',
      name: 'public',
      component: () => import( /* webpackChunkName: "page" */ '@/page/app/public/editor'),
      meta: {
        isAuth: false,
        requireAuth: false,
        keepAlive: true // 用户列表需要被缓存
      }
    },
    {
      path: '/view/:id',
      name: 'view',
      component: () => import( /* webpackChunkName: "page" */ '@/page/view')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import( /* webpackChunkName: "page" */ '@/page/login/index'),
      meta: {
        keepAlive: true,
        isTab: false,
        isAuth: false
      }
    },
    {
      path: '/init',
      name: 'init',
      component: () => import( /* webpackChunkName: "page" */ '@/page/init/index'),
      meta: {
        keepAlive: true,
        isTab: false,
        isAuth: false
      }
    },
    {
      path: '/register',
      name: 'register',
      component: () => import( /* webpackChunkName: "page" */ '@/page/register/index'),
      meta: {
        keepAlive: true,
        isTab: false,
        isAuth: false
      }
    },
    {
      path: '/findPassword',
      name: 'findPassword',
      component: () => import( /* webpackChunkName: "page" */ '@/page/findPassword/index'),
      meta: {
        keepAlive: true,
        isTab: false,
        isAuth: false
      }
    },
    {
      path: '/vform/:appId/:groupId/:worksheetId',
      name: 'vform',
      component: () => import( /* webpackChunkName: "page" */ '@/page/vform/vForm'),
      meta: {
        keepAlive: true,
        isTab: false,
        isAuth: false
      }
    },
    {
      path: '/formDesign',
      name: 'formDesign',
      component: () => import( /* webpackChunkName: "page" */ '@/page/vform/index'),
      meta: {
        keepAlive: true,
        isTab: false,
        isAuth: false
      },
      children: [
        {
          path: '/formDesign/fieldEdit/:appId/:groupId/:worksheetId',
          name: 'fieldEdit',
          component: () => import( /* webpackChunkName: "page" */ '@/page/vform/vForm'),
          meta: {
            keepAlive: true,
            isTab: false,
            isAuth: false
          }
        },{
          path: '/formDesign/formSet/:appId/:groupId/:worksheetId',
          name: 'formSet',
          component: () => import( /* webpackChunkName: "page" */ '@/page/vform/formSet'),
          meta: {
            keepAlive: true,
            isTab: false,
            isAuth: false
          }
        }
      ]
    },
    {
      path: '/worksheet-api/:id',
      name: 'WorksheetApi',
      component: () => import('@/page/worksheet/WorksheetApi'),
      hidden: true,
      // meta: { title: '表单API', keepAlive: false, permission: [ '' ] }
    },
    {
      path: '/customWeb/:appId/:groupId/:worksheetId',
      name: 'customWeb',
      component: () => import('@/page/customWeb/index'),
      hidden: true,
      // meta: { title: '表单API', keepAlive: false, permission: [ '' ] }
    },
    {
      path: '/store', 
      name: 'store',
      component: () => import('@/page/appStore/index') 
    },
    {path: '/', redirect: 'menu'}
  ]
})
export default vueRouter;
